import React, { useEffect } from 'react'
import "./login.less"
import { Button, Checkbox, Form, Input, message } from 'antd';
//离子背景
import ParticlesBg from 'particles-bg'
import { history ,connect} from 'umi';
import axios from 'axios';

type Props = {}

const Index = (props: any) => {
    console.log(props);
    const {dispatch} = props;
    const onFinish = (values: any) => {
      console.log(values);
        dispatch({
            type:"getlogin/getLogin",
            payload:{
                name: values.username,
                password: values.password
            }
        })
    };

    const onFinishFailed = (errorInfo: any) => {
        console.log('Failed:', errorInfo);
    };

    return (
        <div className='login'>
            <ParticlesBg type="polygon"  bg={true}></ParticlesBg>
            <div className='loginbox'>
                <div className='leftbox'>
                    <img src={require("./1.png")} alt="" />
                </div>
                <div className='rightbox'>
                    <div className='loginmain'>
                        <h2>系统登录</h2>
                        <Form
                            name="basic"
                            initialValues={{ remember: true }}
                            onFinish={onFinish}
                            onFinishFailed={onFinishFailed}
                            autoComplete="off"
                        >
                            <Form.Item
                                style={{ margin: "10px 0" }}
                                label="账户"
                                name="username"
                                rules={[{ required: true, message: 'Please input your username!' }]}
                            >
                                <Input style={{ width:"100%",height:"40px" }} placeholder="请输入用户名" />
                            </Form.Item>

                            <Form.Item
                                label="密码"
                                name="password"
                                style={{ margin: "30px 0" }}
                                rules={[{ required: true, message: 'Please input your password!' }]}
                            >
                                <Input.Password style={{ width:"100%",height:"40px" }} placeholder="请输入密码" />
                            </Form.Item>

                            <Form.Item>
                                <Button style={{ width:"100%",height:"40px" }} type="primary" htmlType="submit">
                                    登录
                                </Button>
                            </Form.Item>
                            Or <span onClick={() => {
                                history.push("/register")
                            }}>注册用户</span>
                        </Form>
                    </div>
                </div>
            </div>
        </div>
    )
}

export default connect(({getlogin}:any)=>getlogin)(Index)
